#pragma once

#include "gameobject.h"
#include "../SGD Wrappers/SGD_Math.h"
#include "Physics.h"
#include "Events\IListener.h"

class LaserReflector : public GameObject, public IListener
{
private:

	float rotation;
	tVector2D normal;
	tVector2D startNormal;
	tVector2D surfaceLine;
	tVector2D startSurfaceLine;
	tVector2D renderDirection;
	tVector2D renderPoint;
	float renderDist;
	mutable bool reflectedLaser;
	bool autoRotate;
	bool rotateClockwise;

public:
	// Constructor
	LaserReflector(void);

	// Destructor
	~LaserReflector(void);

	//////////////////////////////////////////////////
	// GameObject Methods:
	virtual void Update(float deltaTime)				override;
	virtual void Render(void) const						override;
	virtual void ResetToCheckPoint()					override;

	virtual void HandleEvent(Event* pEvent)		override;

	//////////////////////////////////////////////////
	// Accessors:
	inline tVector2D GetNormal(void) const { return normal; }

	//////////////////////////////////////////////////
	// Mutators:
	void Rotate(float rotation);
	void RotateClockwise(bool clockwise);
	void SetNormal(float x, float y);
	void SetNormal(tVector2D normal);
	void AutoRotate(bool rotate);
	
	//////////////////////////////////////////////////
	// Methods:
	GameObject* ReflectLaser(tVector2D direction, tVector2D point, float range, LinecastInfo& hitInfo);

private:
	//////////////////////////////////////////////////
	// Helper Functions:
	void DrawLaser(int x1, int y1, int x2, int y2, int iterations) const;
};

